import { useEffect } from "react";
import { useReactive } from "ahooks";
import { useModel } from "umi";
import { useMemberTodoTasks } from "@share-code/public";

export default function messageModal() {
    const { graphqlFetch } = useModel("global");
    const { loadMemberTodoTaskInfo } = useMemberTodoTasks(graphqlFetch);

    const state = useReactive({
        taskUuid: window.taskUuid,
        todoTaskInfo: {},
    });

    const loadTodoTaskInfo = async () => {
        state.todoTaskInfo = await loadMemberTodoTaskInfo(state.taskUuid);
    };

    useEffect(() => {
        state.taskUuid && loadTodoTaskInfo();
    }, [state.taskUuid]);

    return {
        ...state,
    };
}
